package com.esri.core.symbol;

import com.esri.core.internal.util.d;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonNode;

/* loaded from: classes.dex */
public class TextSymbol extends MarkerSymbol {
    public static final String TYPE = "esriTS";
    private static final long serialVersionUID = 1;
    private a g;
    private String h;
    private HorizontalAlignment i;
    private VerticalAlignment j;
    private int k;

    /* loaded from: classes.dex */
    public enum HorizontalAlignment {
        LEFT("left"),
        RIGHT("right"),
        CENTER("center");
        
        String a;

        HorizontalAlignment(String str) {
            this.a = str;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.a;
        }

        public static HorizontalAlignment fromString(String str) {
            if ("left".equals(str)) {
                return LEFT;
            }
            if ("right".equals(str)) {
                return RIGHT;
            }
            if ("center".equals(str)) {
                return CENTER;
            }
            return null;
        }
    }

    /* loaded from: classes.dex */
    public enum VerticalAlignment {
        TOP("top"),
        MIDDLE("middle"),
        BOTTOM("bottom");
        
        String a;

        VerticalAlignment(String str) {
            this.a = str;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.a;
        }

        public static VerticalAlignment fromString(String str) {
            if ("top".equals(str)) {
                return TOP;
            }
            if ("middle".equals(str)) {
                return MIDDLE;
            }
            if ("bottom".equals(str)) {
                return BOTTOM;
            }
            return null;
        }
    }

    public TextSymbol(JsonNode jsonNode) {
        super(jsonNode);
        this.g = new a();
        this.h = null;
        if (jsonNode != null) {
            JsonNode jsonNode2 = jsonNode.get("font");
            if (jsonNode2 != null) {
                this.g = new a(jsonNode2);
            } else {
                this.g = new a(jsonNode);
            }
            this.k = d.b(jsonNode, "color", this.k);
            String a = d.a(jsonNode, "horizontalAlignment");
            if (a != null) {
                try {
                    this.i = HorizontalAlignment.fromString(a);
                } catch (Exception unused) {
                }
            }
            String a2 = d.a(jsonNode, "verticalAlignment");
            if (a2 != null) {
                try {
                    this.j = VerticalAlignment.fromString(a2);
                } catch (Exception unused2) {
                }
            }
            this.h = d.a(jsonNode, "text");
            setWidth(this.g.b());
            setHeight(this.g.b());
        }
    }

    public TextSymbol(int i, String str, int i2, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
        a aVar = new a();
        this.g = aVar;
        this.h = null;
        aVar.a(i);
        a(str, i2, horizontalAlignment, verticalAlignment);
    }

    public TextSymbol(int i, String str, int i2) {
        a aVar = new a();
        this.g = aVar;
        this.h = null;
        aVar.a(i);
        a(str, i2, HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM);
    }

    public TextSymbol(String str, String str2, int i) {
        a aVar = new a();
        this.g = aVar;
        this.h = null;
        aVar.a(str);
        a(str2, i, HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM);
    }

    public TextSymbol(TextSymbol textSymbol) {
        super(textSymbol);
        this.g = new a();
        this.h = null;
        try {
            this.g = textSymbol.g.g();
        } catch (Exception unused) {
            this.g = new a();
        }
        a(textSymbol.getText(), textSymbol.getColor(), textSymbol.getHorizontalAlignment(), textSymbol.getVerticalAlignment());
    }

    private void a(String str, int i, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
        this.h = str;
        this.k = i;
        setWidth(getSize());
        setHeight(getSize());
        this.i = horizontalAlignment;
        this.j = verticalAlignment;
    }

    public String getText() {
        return this.h;
    }

    public TextSymbol setText(String str) {
        this.h = str;
        return this;
    }

    public int getColor() {
        return this.k;
    }

    public void setColor(int i) {
        this.k = i;
    }

    public float getSize() {
        return this.g.b();
    }

    public TextSymbol setSize(float f) {
        this.g.a(f);
        return this;
    }

    @Override // com.esri.core.symbol.Symbol
    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        super.a(a);
        d.a(a, "type", TYPE);
        d.a(a, "xoffset", this.a);
        d.a(a, "yoffset", this.b);
        a.writeFieldName("font");
        a.writeRawValue(this.g.f());
        String str = this.h;
        if (str != null) {
            d.a(a, "text", str);
        }
        d.b(a, "color", this.k);
        VerticalAlignment verticalAlignment = this.j;
        if (verticalAlignment != null) {
            d.a(a, "verticalAlignment", verticalAlignment.toString());
        }
        HorizontalAlignment horizontalAlignment = this.i;
        if (horizontalAlignment != null) {
            d.a(a, "horizontalAlignment", horizontalAlignment.toString());
        }
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    @Override // com.esri.core.symbol.Symbol
    public Symbol copy() throws Exception {
        return new TextSymbol(this);
    }

    public HorizontalAlignment getHorizontalAlignment() {
        return this.i;
    }

    public TextSymbol setHorizontalAlignment(HorizontalAlignment horizontalAlignment) {
        this.i = horizontalAlignment;
        return this;
    }

    public VerticalAlignment getVerticalAlignment() {
        return this.j;
    }

    public TextSymbol setVerticalAlignment(VerticalAlignment verticalAlignment) {
        this.j = verticalAlignment;
        return this;
    }

    public String getFontFamily() {
        return this.g.a();
    }

    public TextSymbol setFontFamily(String str) {
        this.g.a(str);
        return this;
    }

    public FontStyle getFontStyle() {
        return this.g.c();
    }

    public TextSymbol setFontStyle(FontStyle fontStyle) {
        this.g.a(fontStyle);
        return this;
    }

    public FontWeight getFontWeight() {
        return this.g.d();
    }

    public TextSymbol setFontWeight(FontWeight fontWeight) {
        this.g.a(fontWeight);
        return this;
    }

    public FontDecoration getFontDecoration() {
        return this.g.e();
    }

    public TextSymbol setFontDecoration(FontDecoration fontDecoration) {
        this.g.a(fontDecoration);
        return this;
    }

    @Override // com.esri.core.symbol.MarkerSymbol
    public int hashCode() {
        int hashCode = ((super.hashCode() * 31) + this.k) * 31;
        a aVar = this.g;
        int hashCode2 = (hashCode + (aVar == null ? 0 : aVar.hashCode())) * 31;
        HorizontalAlignment horizontalAlignment = this.i;
        int hashCode3 = (hashCode2 + (horizontalAlignment == null ? 0 : horizontalAlignment.hashCode())) * 31;
        String str = this.h;
        int hashCode4 = (hashCode3 + (str == null ? 0 : str.hashCode())) * 31;
        VerticalAlignment verticalAlignment = this.j;
        return hashCode4 + (verticalAlignment != null ? verticalAlignment.hashCode() : 0);
    }

    @Override // com.esri.core.symbol.MarkerSymbol
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (super.equals(obj) && getClass() == obj.getClass()) {
            TextSymbol textSymbol = (TextSymbol) obj;
            if (this.k != textSymbol.k) {
                return false;
            }
            a aVar = this.g;
            if (aVar == null) {
                if (textSymbol.g != null) {
                    return false;
                }
            } else if (!aVar.equals(textSymbol.g)) {
                return false;
            }
            if (this.i != textSymbol.i) {
                return false;
            }
            String str = this.h;
            if (str == null) {
                if (textSymbol.h != null) {
                    return false;
                }
            } else if (!str.equals(textSymbol.h)) {
                return false;
            }
            return this.j == textSymbol.j;
        }
        return false;
    }
}
